package com.tanhua.dubbo.api;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.dubbo.mappers.OptionMapper;
import com.tanhua.model.soul.Choices;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import java.util.Map;

@DubboService
public class OptionApiImpl implements OptionApi {

    @Autowired
    private OptionMapper optionMapper;


    @Override
    public List<Choices> findOption(Long pid) {
        LambdaQueryWrapper<Choices> queryWrapper=new LambdaQueryWrapper<>();

        queryWrapper.eq(Choices::getProblemId,pid);
        List<Choices> options = optionMapper.selectList(queryWrapper);
        return options;
    }

    @Override
    public Map<Long, Choices> findByIds(List<Long> ids, Choices option) {
        QueryWrapper qw = new QueryWrapper();
        //1、用户id列表
        qw.in("id",ids);
        //2、添加筛选条件

        List<Choices> list = optionMapper.selectList(qw);
        Map<Long, Choices> map = CollUtil.fieldValueMap(list, "id");
        return map;
    }


}
